<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>评分标准</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>

    <script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.all.js?20200715.1" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/UEcontroller.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/formdesign/bootstrap/js/bootstrap.js?20200826" type="text/javascript" charset="utf-8"></script>
</head>
<style>
    .mbox {
        padding: 8px
    }

    .item img {
        height: 40px;
    }

    .btn {
        height: 30px;
    }

    .btn button {
        float: right;
    }

    .information {
        background: #e8f4fc;
        height: 30px;
        line-height: 30px;
    }

    .add {
        height: 30px;
    }

    .layui-form-item {
        margin-bottom: 5px;
    }
    .layui-input-inline{
        width: 300px !important;
    }

    .openFile input[type=file]{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }
</style>
<body>
<div class="mbox">
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">评分标准</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="btn">
        <button type="button" class="layui-btn layui-btn-sm" style="background: #2b7fe0"><i
                class="layui-icon layui-icon-upload-drag" style="vertical-align: inherit"></i>导出
        </button>
    </div>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
</body>
</html>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="startreview">开始评审</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="ndreview">结束审评</a>
</script>
<script>

    var ue;   //编辑器的返回值
    var table,form,laydate,upload,layedit;
    //关闭弹框刷新页面
    function closes(){
        layer.closeAll();
        table.reload('test');
    }

    layui.use(['table', 'form', 'laydate','upload','layedit'], function () {
        table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            upload = layui.upload,
            layedit = layui.layedit;


        var tableInt = table.render({
            elem: '#test'
            ,url:'/rpmPlan/selectAll'
            ,where:{
                isReview:'2'
            }
            , title: '用户数据表'
            , cols: [[
                {field: 'planName', title: '计划名称' ,align:'center'}
                , {field: 'state', title: '计划状态' ,align:'center' ,templet: function(d){
                        if(d.state=='1'){
                            return '申报中'
                        }else{
                            return '申报结束'
                        }
                    }}
                , {field: 'reviewStatus', title: '评审状态' ,align:'center' , templet: function(d){
                        if(d.reviewStatus=='1'){
                            return '未开始'
                        }else if(d.reviewStatus == '2'){
                            return '评审中'
                        }else if (d.reviewStatus == '3'){
                            return '评审结束'
                        }
                        return '';
                    }}
                // , {field: 'num', title: '申报数量',align:'center'}
                // , {field: 'bynum', title: '通过数量',align:'center'}
                // , {field: 'expert', title: '专家人数',align:'center'}
                , {field: 'beginDate', title: '评审开始日期',align:'center'}
                , {field: 'endDate', title: '评审结束日期',align:'center'}
                , {field: 'scoreRule', title: '评分标准',align:'center'}
                , {field: 'type', title: '操作', toolbar: '#barDemo',width:350 ,align:'center'}
            ]]
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code":0, //解析接口状态
                    "data": res.object, //解析数据列表，
                    "count": res.totleNum, //解析数据长度
                };
            }
            , page: true
        });

        /*新建和编辑的方法*/
        function creat(type,planId) {
            layer.open({
                type: 2,
                title: '编辑',
                btn: ['确定', '取消'],
                shade: 0.5,
                maxmin: true, //开启最大化最小化按钮
                area: ['60%', '80%'],
                content: '/rpmPlan/gradingEdit?planId='+ planId ,
                yes:function (index, layero) {
                    var myIframe = window[layero.find('iframe')[0]['name']];
                    var fnc = myIframe.submitEdit();
                }
            })
        }

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            var planId = data.planId
            var reviewStatus = data.reviewStatus
            if(obj.event === 'edit'){
                creat(1,planId)
            }else if(obj.event === 'startreview'){

                layer.confirm('确定开始评审?', {icon: 3, title:'提示'}, function(index){
                    $.ajax({
                        type: 'get',
                        url: '/rpmPlan/updateByKey',
                        data:{
                            planId:planId,
                            reviewStatus : '2'
                        },
                        dataType: 'json',
                        success: function (res) {
                            if (res.flag) {
                                layer.msg('已开始！', {icon: 1});
                                tableInt.reload()
                            }
                        }
                    })
                    layer.close(index);
                });
            }else if(obj.event === 'ndreview'){
                layer.confirm('确定结束评审?', {icon: 3, title:'提示'}, function(index){
                    $.ajax({
                        type: 'get',
                        url: '/rpmPlan/updateByKey',
                        data:{
                            planId:planId,
                            reviewStatus : '3'
                        },
                        dataType: 'json',
                        success: function (res) {
                            if (res.flag) {
                                layer.msg('已结束！', {icon: 1});
                                tableInt.reload()
                            }
                        }
                    })
                    layer.close(index);
                });
            }
        });

        //删除附件
        $(document).on('click', '.deImgs', function () {
            var _this = this;
            var attUrl = $(this).parents('.dech').attr('deUrl');
            layer.confirm('确定删除该附件吗？', function (index) {
                $.ajax({
                    type: 'get',
                    url: '/delete?' + attUrl,
                    dataType: 'json',
                    success: function (res) {

                        if (res.flag == true) {
                            layer.msg('删除成功', {icon: 6, time: 1000});
                            $(_this).parent().remove();
                        } else {
                            layer.msg('删除失败', {icon: 2, time: 1000});
                        }
                    }
                })
            });
        });
    });
</script>
